package com.san.metadata.task;

import java.util.concurrent.Callable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.san.metadata.dao.OperationMetadataManager;
import com.san.metadata.domain.ManageTableDO;

/**
 * 管理元数据归集线程
 * 
 * @author xiangyz
 *
 */
public class DataProcessThread implements Callable<Long> {

	private static final Logger logger = LoggerFactory.getLogger(DataProcessThread.class);

	/**
	 * 操作元数据JDBC数据访问管理
	 */
	private OperationMetadataManager operationMetadataManager;
	
	private ManageTableDO manageTableDO;

	/**
	 * 批次号
	 */
	private Long batchNo;

	/**
	 * 任务ID
	 */
	private Long jobId;

	public DataProcessThread(OperationMetadataManager operationMetadataManager,ManageTableDO manageTableDO, Long batchNo, Long jobId) {
		this.operationMetadataManager = operationMetadataManager;
		this.manageTableDO = manageTableDO;
		this.batchNo = batchNo;
		this.jobId = jobId;
	}

	@Override
	public Long call() throws Exception {
		logger.info("数据归集begin...." + jobId);

		ThreadLocal<OperationMetadataManager> serviceLocal = new ThreadLocal<OperationMetadataManager>();
		serviceLocal.set(operationMetadataManager);

		// 数据同步至技术元数据
		return serviceLocal.get().processManageMetadata(batchNo, jobId, manageTableDO);
	}

}
